<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://xmlns.jcp.org/jsf/html"
      xmlns:p="http://primefaces.org/ui"
      xmlns:f="http://xmlns.jcp.org/jsf/core">
    <h:head>
            
    </h:head>
    <h:body style="background-color: background;">
        

        
        <h:form style="size: landscape;">
            <p:panelGrid columns="8" style=" max-width: 85%;margin-top: 2%; margin-left: auto ; margin-right: auto;">
    
        <p:outputLabel value="Logged User: #{userBean.name}" />
        
        <p:commandLink  action="#{calendarBean.home()}" value="Home"/>
        <p:commandLink  action="#{calendarBean.invitation()}" value="invitation"/>
        <p:commandLink  action="#{calendarBean.notification()}" value="notification"/>
        <p:commandLink  action="#{calendarBean.favorite()}" value="favorite"/>
        
        <h:panelGrid columns="3" style="max-width: fit-content" >
            <h:outputLabel for="searchUsr" value="Search User: " />
            <p:autoComplete id="autoUser" value="#{autoCompleteUsers.searched}" completeMethod="#{autoCompleteUsers.completeText}" forceSelection="true"/>
            <p:commandButton id="cmdSubmit" value="Submit" icon="ui-icon-check" action="#{autoCompleteUsers.visitUser}" update="messages" />
        </h:panelGrid>
        
        <h:panelGrid columns="3" style="max-width: fit-content">
            <h:outputLabel for="searchEvt" value="Search Event: " />
            <p:autoComplete id="autoEvent" value="#{autoCompleteEvent.searched}" completeMethod="#{autoCompleteEvent.completeText}" forceSelection="true"/>
            <p:commandButton id="cmdSubmitEvent" value="Submit" icon="ui-icon-check" action="#{autoCompleteEvent.visitEvent}" update="messages" />
        </h:panelGrid>
        
        <p:commandLink  action="#{loginBean.logout()}" value="logout"/>
    </p:panelGrid>
            
    <p:growl id="messages" autoUpdate="true" globalOnly="true" showDetail="true" life="3000" />
    
    <h:panelGrid style="background-color: background; max-width: 65%; margin-top:2%; min-width: 400px; margin-bottom: 5%; margin-left: auto; margin-right: auto; " columns="2" columnClasses="label,value" >
        
        <h:panelGrid id="infoGrid" columns="1" style="background-color: background; max-width: 80%; margin-left: auto; margin-right: 5%; margin-top: 30%; margin-bottom: auto;">
            <p:panelGrid id="infoField" columns="2"> 
            <p:outputLabel value="Name: "/>
            <p:outputLabel value="#{calendarBean.loggedUser.name}" style="text-align: center"/>
            <p:outputLabel value="Surname: "/>
            <p:outputLabel value="#{calendarBean.loggedUser.surname}" style="text-align: center"/>
            <p:outputLabel value="Email: "/>
            <p:outputLabel value="#{calendarBean.loggedUser.email}" style="text-align: center"/>
            <p:outputLabel value="Birthday: "/>
            <p:outputLabel id="birth" value="#{calendarBean.loggedUser.birthday.time}" style="text-align: center" />
            <p:outputLabel value="Address: "/>
            <p:outputLabel value="#{calendarBean.loggedUser.address}" style="text-align: center"/>
            <p:outputLabel value="City: "/>
            <p:outputLabel value="#{calendarBean.loggedUser.city}" style="text-align: center"/>
            <p:outputLabel value="Public Calendar: "/>
            <h:selectBooleanCheckbox id="privateCal" readonly="true" disabled="true" value="#{calendarBean.loggedUser.privacy}" style="text-align: center" />
            </p:panelGrid>
            <p:commandButton value="Edit Informations" update="userDetails" onclick="PF('userInfo').show();" style="width: 80%; margin-left: 10%"/>
        </h:panelGrid>
        
        <p:schedule id="schedule" style="max-width: 90%; margin-top:5%; min-width: 400px; margin-bottom: 5%; margin-left: auto; margin-right: auto;" value="#{calendarBean.eventModel}" widgetVar="myschedule" draggable="false" timeZone="GMT+1">
 
           
            <p:ajax event="dateSelect" listener="#{calendarBean.onDateSelect}" update="eventDetails" oncomplete="PF('eventDialog').show();" />
            <p:ajax event="eventSelect" listener="#{calendarBean.onEventSelect}"  update="eventDetails" oncomplete="PF('eventDialog').show();" />
 
        </p:schedule>
    </h:panelGrid>
    
    <p:dialog id="dlgEvent" resizable="false" widgetVar="eventDialog" style=" width:300px; height: 450px;" header="Event Details" showEffect="clip" dynamic="true" hideEffect="clip">
        <p:panelGrid id="eventDetails" columns="2">  

            <h:outputLabel for="title" value="Title:" />
            <p:inputText id="title" readonly="#{not calendarBean.event.editable}" value="#{calendarBean.event.title}"  />
            
            <h:outputLabel for="place" value="Place:" />
            <p:inputText id="place" value="#{calendarBean.event.place}" readonly="#{not calendarBean.event.editable}" />
            
            <h:outputLabel for="from" value="From:" />
            <p:inputMask id="from" value="#{calendarBean.event.startDate}" readonly="#{not calendarBean.event.editable}"  mask="99/99/9999 99:99:99">
                <f:convertDateTime pattern="dd/MM/yyyy HH:mm:ss" timeZone="GMT+1" />
            </p:inputMask>
 
            <h:outputLabel for="to" value="To:" />
            <p:inputMask id="to" value="#{calendarBean.event.endDate}" readonly="#{not calendarBean.event.editable}" mask="99/99/9999 99:99:99">
                <f:convertDateTime pattern="dd/MM/yyyy HH:mm:ss" timeZone="GMT+1"/>
            </p:inputMask>
 
            <h:outputLabel for="Public" value="Public:"  />
            <h:selectBooleanCheckbox id="public" value="#{calendarBean.event.visible}" disabled="#{not calendarBean.event.editable}" readonly="#{not calendarBean.event.editable}" />
 
            <h:outputLabel for="Outdoor" value="Outdoor:"  />
            <h:selectBooleanCheckbox id="outdoor" value="#{calendarBean.event.outdoor}" disabled="#{not calendarBean.event.editable}" readonly="#{not calendarBean.event.editable}" />
            
            <p:outputLabel for="invite" value="Invite:" rendered="#{calendarBean.event.editable}"/>
            <p:selectManyMenu id="invite" value="#{selectManyView.selectedEmails}" rendered="#{calendarBean.event.editable}"
                          var="t" filter="true" filterMatchMode="contains" showCheckbox="#{calendarBean.event.editable}" >
                <f:selectItems value="#{selectManyView.emails}" var="s"  itemValue="#{string}" />
                <p:column>
                <h:outputText value="#{t}" />
            </p:column>
        </p:selectManyMenu>
            
        <h:outputLabel value="Creator: " rendered="#{not calendarBean.event.editable}"/>
        <p:outputLabel value="#{calendarBean.event.emailCreator}" rendered="#{not calendarBean.event.editable}"/>
        
        <h:outputLabel for="badW" value="Bad Weather:" rendered="#{calendarBean.event.editable}" />
        <p:selectOneListbox id="badWeather" value="#{badWeatherCondition.badWeatherSelected}" var="a" rendered="#{calendarBean.event.editable}">
            <f:selectItems  var="b" value="#{badWeatherCondition.badWeathers}" itemValue="#{string}"  />
            <p:column>
                <h:outputText value="#{a}" />
            </p:column>
                
        </p:selectOneListbox>
        
        
        <p:commandButton id="removeInv" value="Remove" update="schedule" rendered="#{calendarBean.deletable}" actionListener="#{calendarBean.removeEvent()}" oncomplete="PF('myschedule').update();PF('eventDialog').hide();" />
        
        <p:outputLabel rendered="#{not calendarBean.deletable}" value="" />
        
        <p:commandButton id="addButton" value="Save" update="schedule" rendered="#{calendarBean.event.editable}" actionListener="#{calendarBean.addEvent}" oncomplete="PF('myschedule').update();PF('eventDialog').hide();" />

        
        </p:panelGrid>
    </p:dialog>  
    
    <p:dialog id="infoUser" resizable="false" widgetVar="userInfo" header="User Info" showEffect="clip" dynamic="true" hideEffect="clip">
        <p:panelGrid id="userDetails" columns="2"> 
            <p:outputLabel value="Name: "/>
            <p:inputText value="#{calendarBean.modifyUser.name}" />
            <p:outputLabel value="Surname: "/>
            <p:inputText value="#{calendarBean.modifyUser.surname}"/>
            <p:outputLabel value="Birthday: "/>
            <p:inputMask id="birthday" value="#{calendarBean.modifyBirthday}"  mask="99/99/9999">
                <f:convertDateTime pattern="dd/MM/yyyy" timeZone="GMT+1" />
            </p:inputMask>
            <p:outputLabel value="Address: "/>
            <p:inputText value="#{calendarBean.modifyUser.address}"/>
            <p:outputLabel value="City: "/>
            <p:inputText value="#{calendarBean.modifyUser.city}"/>
            <p:outputLabel value="Public Calendar: "/>
            <h:selectBooleanCheckbox value="#{calendarBean.modifyUser.privacy}"/>
            <p:commandButton value="Submit" actionListener="#{calendarBean.submitModifyUser()}" update="infoField" oncomplete="PF('userInfo').update; PF('userInfo').hide();" />
            </p:panelGrid>
    </p:dialog>  
    
    <!--DA RISOLVERE PROBLEMA MESSAGGIO-->
</h:form>
 
<style type="text/css">
    .value {
        width: 1000px;
    }
</style>
    </h:body>
</html>
